package com.mocha.bss.domain.org.repository.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.coffee.core.EnumValid;
import com.coffee.core.ValidGroup;
import com.coffee.mybatis.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * @author songkui
 * @since 2022-03-17
 */

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(of ={"loginCode"}, callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
public class UserEntity extends TenantEntity {

    private static final long serialVersionUID = 1L;

    @NotNull(groups = ValidGroup.Update.class, message = "应用ID不能为空")
    @Null(groups = ValidGroup.Create.class, message = "应用ID必须为空")
    @TableId(type = IdType.AUTO)
    private Integer id;

    @NotBlank(groups = ValidGroup.Create.class, message = "账号必填")
    @TableField("login_code")
    private String loginCode;

    @Length(groups = ValidGroup.Create.class, min = 6,max = 12, message = "长度必须位于6到12之间")
    @TableField("login_passward")
    private String loginPassward;

    @TableField("wx_open_id")
    private String wxOpenId;

    @TableField("wx_name")
    private String wxName;

    @TableField("mobile")
    private String mobile;

    @TableField("nickname")
    private String nickname;


    @TableField(exist = false)
    @EnumValid(value = {"xxx"}, message = "xdsfsdsdsd")
    private String gender;


}
